﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="UserControl_UC_SearchBar" Codebehind="UC_SearchBar.ascx.cs" %>
<div class="SearchBar">
    &nbsp;<b> 站内搜索：</b>&nbsp;&nbsp;
    <input id="txtKeyWord" type="text"/>&nbsp;
    <select id="ddlSort">
        <option selected="selected" value="{ModelPath}/SoftSearch.aspx?Sort=SoftName&Keyword=">软件名称</option>
        <option value="/Soft/SoftSearch.aspx?Sort=Content&Keyword=">软件简介</option>
        <option value="/Article/ArticleSearch.aspx?Sort=Title&Keyword=">文章标题</option>
        <option value="/Article/ArticleSearch.aspx?Sort=Author&Keyword=">文章作者</option>
        <option value="/Article/ArticleSearch.aspx?Sort=Content&Keyword=">文章内容</option>
    </select>&nbsp;&nbsp;
    <input type="button" name="Button" class="btn" onclick=" GoTo(); " value="搜索"/>
</div>
<script type="text/javascript">
    Request =
    {
        QueryString: function(item) {
            var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
            return svalue ? svalue[1] : svalue;
        }
    }
    if (Request.QueryString("KeyWord") != null) {
        document.getElementById('txtKeyWord').value = Request.QueryString("KeyWord");
    }

    function GoTo() {
        var k = document.getElementById('ddlSort');
        var getvalue = k.options[k.selectedIndex].value; //被选中项的值
        var key = document.getElementById('txtKeyWord').value;
        var url = getvalue + key + "&PageNo=1";
        window.open(url, '_blank');
    }
</script>